<template>
    <keep-alive>
        <div class="appWindow">
            <div class="content">
                <div class="bar">————</div>
                <component :is="remote" v-if="remote"></component>
                <div class="bottomTool"><span @click="closeApp">X</span></div>
            </div>
            <div class="icon">{{ props.packageName }}</div>
        </div>
    </keep-alive>
</template>


<script setup lang="ts">
import { defineAsyncComponent, ref, Ref } from "vue";
import appModel from "./model"

let props: Record<string, any> = defineProps(["packageName"])
interface Component { }
let app = new appModel()
let remote: Ref<Component | null> = ref(null)
app.init(props.packageName).then(() => {
    remote.value = defineAsyncComponent(() => app.el())
})

function closeApp(){
    
}
</script>

<style scoped>
.appWindow {
    position: fixed;
    width: 90%;
    top: 10%;
    left: 10%;
    background: white;
    transition: all 0.01s;
}

.bar {
    width: 100%;
    text-align: center;
    background-color: aqua;
    user-select: none;
    border-top-right-radius: 15px;
    border-top-left-radius: 15px;
}

.bottomTool {
    background-color: aqua;
    display: flex;
}

.icon {
    width: 60px;
    height: 60px;
    text-wrap: wrap;
    word-break: break-all;
    overflow: hidden;
}
</style>